
package poplar.dp.test;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.security.Security;
import java.util.Hashtable;

import org.jboss.sasl.JBossSaslProvider;

import poplar.dc.user.*;

public class testRemoteObj {
	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}
	
	public UserRemote lookupRemoteStateless() throws NamingException{
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        final Context context = new InitialContext(jndiProperties);
        final String appName = "";
        final String moduleName = "datacenter";
        final String distinctName = "";
        final String beanName = UserBean.class.getSimpleName();
        final String viewClassName = UserRemote.class.getName();
        return (UserRemote)context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);
    }
	
	@Test
	public void testUserBean(){
		long uid = 0;
		String regDate = "";
		
		try{
			UserRemote user = lookupRemoteStateless();			
			uid = user.getUid("apov");
			regDate = user.getRegDate( uid );
		} 
		catch( Exception e ){
			   // TODO Auto-generated catch block
			e.printStackTrace();
		}	
	}	
}
